﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ChinaClipping.ClippingMaster.Editor
{
    class PathHelper
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern uint GetShortPathName(
           [MarshalAs(UnmanagedType.LPTStr)]
    string lpszLongPath,
           [MarshalAs(UnmanagedType.LPTStr)]
    StringBuilder lpszShortPath,
           uint cchBuffer);

        public static StringBuilder shortNameBuffer = new StringBuilder(256);
        public static string ToShortPathName(string longName)
        {
            uint result = GetShortPathName(longName, shortNameBuffer, 256);
            return shortNameBuffer.ToString();
        }
    }
}
